import 'package:flutter/material.dart';


/// @Description: widget的扩展类,可以方便快速创建点击事件
extension WidgetExtension on Widget {

  /// 点击事件
  /// [showHighlight] 是否显示水波纹
  /// ```dart
  /// Container(
  ///   child: Text('点击我'),
  /// ).click(() {
  ///   print('点击了我');
  /// });
  /// ```
  Widget click(VoidCallback onTap, {
    bool showHighlight = false,
    VoidCallback? onLong,
  }) {
    return InkWell(
      highlightColor: showHighlight ? null : Colors.transparent,
      splashColor: showHighlight ? null : Colors.transparent,
      onTap: onTap,
      onLongPress: onLong,
      child: this,
    );
  }
}